-- 双豌豆射手类
local Plant = require("app.mode.Plant")
local PeaShooter = require("app.mode.PeaShooter")

local DoubleShooter = {}
setmetatable(DoubleShooter, PeaShooter)
DoubleShooter.__index = DoubleShooter

-- 重写功能函数
function DoubleShooter:doFunc()
    local x, y = self:getLogicPosition()
    
    if self._scene and Plant:getZCount(y) > 0 then
        x, y = self:getPosition()
        
        -- 发射第一颗豌豆
        self:newWeapon("pea", x + 20, y + 24)
        
        local timer, scheduler
        scheduler = cc.Director:getInstance():getScheduler()
        timer = scheduler:scheduleScriptFunc(
            function(delta)
                scheduler:unscheduleScriptEntry(timer)
                -- 发射第二颗豌豆
                self:newWeapon("pea", x + 20, y + 24)
            end,
            0.3,
            false
        )
    end
end

return DoubleShooter
